let f7 = null;
let dialog = null;

class Alert {
  static init(app) {
    f7 = app;
  }

  static show(param, animate = true) {
    Alert.dismiss();
    dialog = f7.dialog.create(param).open(animate);
  }

  static preloader(title, color) {
    Alert.dismiss();
    dialog = f7.dialog.preloader(title, color);
  }

  static progress(title, progress, color) {
    Alert.dismiss();
    dialog = f7.dialog.progress(title, progress, color);
  }

  static dismiss(animate = true) {
    let result = false;
    if (null != dialog && dialog.opened) {
      // dialog.close(animate).destroy()
      dialog.close(animate)
      dialog = null
      result = true
    }

    return result;
  }
}

export default Alert;
